import axios from 'axios'
import qs from 'qs'

// const host = 'http://www.900show.com:8888/yfsjb'
// const front = 'http://www.900show.com:8888/dis/index.html/#'
const host = '/yfsjb'
// const host = 'http://127.0.0.1:8081'
const front = '/dis/index.html/#'
const oauth2 = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd144053eb04e2e33&redirect_uri=http%3a%2f%2fyunfu.streaminfo.cn%2fyfsjb%2fwechat&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect'
const apiAnnual = {
  getQuestionsByType: host.concat('/yf/getQuestionByTypeId'),
  getQuestionsByRandom: host.concat('/yf/getRandomQuestion'),
  getQuestionType: host.concat('/yf/getQuestionType'),
  getBackground: host.concat('/yf/getBackground'),
  getRule: host.concat('/yf/getRule'),
  getLRule: host.concat('/yf/getLRule'),
  isCanPrize: host.concat('/yf/isCanPrize'),
  prize: host.concat('/yf/prize'),
  savePrize: host.concat('/yf/savePrizeRecord')
}
export default {
  getHost () {
    return host
  },
  getFront () {
    return front
  },
  getOAuth2 () {
    return oauth2
  },
  getQuestionsByType (_questionType) {
    return axios.get(apiAnnual.getQuestionsByType, {
      params: {
        questionType: _questionType
      }
    })
  },
  getQuestionsByRandom (_difficulty) {
    return axios.get(apiAnnual.getQuestionsByRandom, {
      params: {
        num: 3,
        difficulty: _difficulty
      }
    })
  },
  getQuestionType () {
    return axios.get(apiAnnual.getQuestionType, {
      params: {
      }
    })
  },
  getBackground () {
    return axios.get(apiAnnual.getBackground, {
      params: {
      }
    })
  },
  getRule () {
    return axios.get(apiAnnual.getRule, {
      params: {
      }
    })
  },
  getLRule () {
    return axios.get(apiAnnual.getLRule, {
      params: {
      }
    })
  },
  isCanPrize (_userId) {
    return axios.get(apiAnnual.isCanPrize, {
      params: {
        userId: _userId
      }
    })
  },
  prize (_userId, _prizeId) {
    return axios.post(apiAnnual.prize, qs.stringify({
      userId: _userId,
      prizeId: _prizeId
    }))
  },
  savePrize (_id, _tel) {
    return axios.post(apiAnnual.savePrize, qs.stringify({
      id: _id,
      tel: _tel
    }))
  }
}
